package shujujiegou.Duigui.duoluDuiugi;

import java.util.LinkedList;

public class hanluota {
    static LinkedList<Integer> a=new LinkedList<>();
    static LinkedList<Integer> b=new LinkedList<>();
    static LinkedList<Integer> c=new LinkedList<>();
    static void init(int n){
        for (int i = n; i >= 1; i--) {
            a.addLast(i);
        }
    }
    public static void main(String[] args) {
        init(3);
        movie(3,a,b,c);
        print();
  /*      init(3);
        print();
        b.addLast(a.removeLast());
        print();*/
    }

    /**
     *
     * @param n 圆盘个数
     * @param a 源
     * @param b 借
     * @param c 目
     */
    static void movie(int n,LinkedList<Integer> a,
                      LinkedList<Integer> b,
                      LinkedList<Integer> c){
        if (n==0){

            return;
        }
        movie(n-1,a,c,b);
        c.addLast(a.removeLast());
        movie(n-1,b,a,c);
    }
    private static void print() {
        System.out.println("------------------------");
        System.out.println(a);
        System.out.println(b);
        System.out.println(c);
    }
}
